package cm.utils;

import java.util.concurrent.*;

import com.google.common.util.concurrent.ThreadFactoryBuilder;

public class ThreadPoolUtils {
    private static ThreadFactory namedFactory = new ThreadFactoryBuilder().setNameFormat("thread-pool-%d").build();
    private static ExecutorService pool;

    public static ExecutorService getPool(){
        return getInstance();
    }
    public static ExecutorService getInstance(){
        if (pool == null){
            pool = new ThreadPoolExecutor(50,100,0L,
                    TimeUnit.MICROSECONDS,new LinkedBlockingDeque<Runnable>(1024),namedFactory,new ThreadPoolExecutor.AbortPolicy());
        }
        return pool;
    }
	
	public static void main(String[] args) {
        ThreadPoolUtils.getPool().execute(()-> System.err.println("线程池"));
    }
}
